Skip to content

[release/11.0-preview6] Fix async resumption stub with byref parameters#130022

Merged
svick merged 3 commits into
release/11.0-preview6from
backport/pr-129999-to-release/11.0-preview6
Jul 1, 2026
Merged

[release/11.0-preview6] Fix async resumption stub with byref parameters#130022
svick merged 3 commits into
release/11.0-preview6from
backport/pr-129999-to-release/11.0-preview6

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Backport of #129999 to release/11.0-preview6

/cc @jakobbotsch

Customer Impact

  • Customer reported
  • Found internally

A Task-returning method A with a byref parameter may cause the runtime to throw an InvalidProgramException if directly returning the result of another Task-returning method B(), the task returned by B suspends and also one of the following is true:

  • A is marked with [MethodImpl(MethodImplOptions.NoInlining)]
  • B returns Task<T> and A returns Task

In these cases the runtime produces an internal IL stub with invalid IL. The invalid IL tries to zero a byref local using initobj, which is not legal IL. Reported by ASP.NET in #129990.

Regression

  • Yes
  • No

This issue exists since runtime async was introduced, but #128384 made it possible to hit this issue from C# code.

Testing

Unit test introduced.

Risk

Low. Adjust IL emission to load a byref zero without initobj.

It is not valid IL to initialize a byref local with `initobj`. Just load
the value of these directly.

We had a test for byref parameters, but it did not suspend and did not
result in creation of a resumption stub. The test case requires
suspension + NoInlining to guarantee a suspension point is created.
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@JulieLeeMSFT JulieLeeMSFT added the Servicing-consider Issue for next servicing release review label Jun 30, 2026
@JulieLeeMSFT JulieLeeMSFT added this to the 11.0.0 milestone Jun 30, 2026
@JulieLeeMSFT

Copy link
Copy Markdown
Member

/ba-g all known issues.

@JulieLeeMSFT JulieLeeMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jun 30, 2026
@JulieLeeMSFT

Copy link
Copy Markdown
Member

@svick, it is ready to merge.

@svick svick merged commit b492b5e into release/11.0-preview6 Jul 1, 2026
134 of 141 checks passed
@svick svick deleted the backport/pr-129999-to-release/11.0-preview6 branch July 1, 2026 09:09
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview6 Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-VM-coreclr Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants